package p1;

/**
 * Created with IntelliJ IDEA.
 * Description:匿名内部类
 * User: LianBao
 * Date: 2024-06-06
 * Time: 19:21
 */
public class demo4 {
    public static void main(String[] args) {
        Runnable runnable = new MyRunnable() {
            @Override
            public void run() {
                System.out.println("Hello Thread");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        };
        Thread t = new Thread(runnable);
        //
        Thread t2 = new Thread(new MyRunnable() {
            @Override
            public void run() {
                System.out.println("Hello Thread");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });
        t.start();
        while (true) {
            System.out.println("Hello main");
        }
    }
}
